package com.cardone.platform.authority.service;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import com.cardone.common.cache.Caches;
import com.cardone.common.dto.PaginationDto;
import com.cardone.platform.authority.dto.PermissionDto;

/**
 * 许可服务
 *
 * @author yaohaitao
 */
public interface PermissionService {
	/**
	 * spring bean id
	 */
	String BEAN_ID = "com.cardone.platform.authority.service.PermissionService";

	/**
	 * 保存:许可
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param savePermission
	 *          许可对象
	 *
	 * @return 许可对象
	 */
	@Deprecated
	@CacheEvict(value = { RoleService.BEAN_ID, PermissionService.BEAN_ID }, allEntries = true)
	<P> P saveByIdOrCode(final Class<P> mappedClass, final PermissionDto savePermission);

	/**
	 * 插入
	 *
	 * @param insertPermission
	 *          许可对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@CacheEvict(value = { RoleService.BEAN_ID, PermissionService.BEAN_ID }, allEntries = true)
	int insertByCode(final PermissionDto insertPermission);

	/**
	 * 删除
	 *
	 * @param deletePermission
	 *          许可对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@CacheEvict(value = { RoleService.BEAN_ID, PermissionService.BEAN_ID }, allEntries = true)
	int deleteByIds(final PermissionDto deletePermission);

	/**
	 * 更新
	 *
	 * @param updatePermission
	 *          许可对象
	 *
	 * @return 影响行数
	 */
	@Deprecated
	@CacheEvict(value = { RoleService.BEAN_ID, PermissionService.BEAN_ID }, allEntries = true)
	int updateByCode(final PermissionDto updatePermission);

	/**
	 * 查询
	 *
	 * @param readPermission
	 *          许可对象
	 * @return 返回数据
	 */
	@Deprecated
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_1)
	Integer readByCodeNqIdForCount(final PermissionDto readPermission);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findPermission
	 *          许可对象
	 * @return 返回对象
	 */
	@Deprecated
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	<P> P findById(final Class<P> mappedClass, final PermissionDto findPermission);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findPermission
	 *          许可对象
	 *
	 * @return 返回对象
	 */
	@Deprecated
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	<P> P findByCodeOrId(final Class<P> mappedClass, final PermissionDto findPermission);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param findListPermission
	 *          许可对象
	 *
	 * @return 许可对象集合
	 */
	@Deprecated
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	<P> List<P> findListByLikeCode(final Class<P> mappedClass, final PermissionDto findListPermission);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 * @param siteId
	 *          站标识
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	<P> List<P> findListBySiteId(final Class<P> mappedClass, final String siteId);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 * @param siteId
	 *          站标识
	 * @param roleId
	 *          角色标识
	 *
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_3)
	<P> List<P> findListBySiteIdAndRoleId(final Class<P> mappedClass, final String siteId, final String roleId);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 * @param siteId
	 *          站标识
	 * @param typeId
	 *          类别标识
	 *
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_3)
	<P> List<P> findListBySiteIdAndTypeId(final Class<P> mappedClass, final String siteId, final String typeId);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 * @param siteId
	 *          站标识
	 * @param typeCode
	 *          类别代码
	 *
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_3)
	<P> List<P> findListBySiteIdAndTypeCode(final Class<P> mappedClass, final String siteId, final String typeCode);

	/**
	 * 查询
	 *
	 * @param siteId
	 *          站标识
	 * @param typeCode
	 *          类别代码
	 *
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	List<String> readCodeListBySiteIdAndTypeCode(final String siteId, final String typeCode);

	/**
	 * 查询
	 *
	 * @param mappedClass
	 *          返回类型
	 * @param siteId
	 *          站标识
	 * @param roleIdList
	 *          角色标识集合
	 *
	 * @return 许可对象集合
	 */
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_3)
	<P> List<P> findListBySiteIdAndRoleIdList(final Class<P> mappedClass, final String siteId, final List<String> roleIdList);

	/**
	 * 分页
	 *
	 * @param mappedClass
	 *          返回类型
	 *
	 * @param paginationPermission
	 *          许可对象
	 *
	 * @return 许可分页对象
	 */
	@Deprecated
	@Cacheable(value = PermissionService.BEAN_ID, key = Caches.KEY_2)
	<P> PaginationDto<P> paginationByLikeCode(final Class<P> mappedClass, final PermissionDto paginationPermission);

}